<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // class语法
        //  构造函数和原型
        // function Person(name,  age) {
        //     this.name = name
        //     this.age = age
        // }

        // let p = new Person('jack', 20);

        // Person.prototype.sayHello = function() {
        //     console.log(this.name)
        // }

        // 应用场合 ： React 类组件

        class Person{
            constructor(name,age){
                this.name = name;
                this.age = age;
            }

            sayHello(){
                console.log('大家好！我是' + this.name)
            }

            eat() {
                console.log('在吃东西')
            }
        }

        let p = new Person('jack', 20)
        p.sayHello()

        let p1 = new Person('rOSE', 19)
        p1.sayHello()
    </script>
</body>
</html>